﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

using ECCIT.Extension.Weibo_v2.Common;
using OgilvyOne.UKNow.BLL;
using OgilvyOne.UKNow.Mobile.Model.Events;
using OgilvyOne.UKNow.Mobile.Utilities;
using OgilvyOne.UKNow.Model;

namespace OgilvyOne.UKNow.Mobile.APIs.Events
{
    public class GetDates : IHttpHandler
    {
        public bool IsReusable { get { return false; } }

        public void ProcessRequest(HttpContext context)
        {
            try
            {
                string yearMonth = context.Request.Params["yearMonth"];
                string sCityID = context.Request.Params["city"];
                yearMonth = yearMonth != null ? yearMonth.Replace("/", "-") : "";               
                int cityID = string.IsNullOrEmpty(sCityID) ? 0 : int.Parse(sCityID);
            
                IList<int> dates = new EventsBLL(2052).GetAllPublishedEventsDate(cityID, 0, yearMonth);
                string s = JsonSerializationHelper.ObjectToJson(dates);
                context.Response.Write(ResultUtility.ReturnResultJson("0", s, "获取活动日期数据成功"));
            }
            catch (Exception ex)
            {
                context.Response.Write(ResultUtility.ReturnResultJson("-710", "", "获取活动日期数据失败. Message:" + ex.Message));

            }
        }
    }
}
